<?php

use Illuminate\Database\Seeder;
use WoXuanWang\User\Models\User;
use WoXuanWang\Company\Models\Company;
use WoXuanWang\Customer\Models\Customer;
use WoXuanWang\DataHistory\Models\DataHistory;
use WoXuanWang\DeviceType\Models\DeviceType;
use WoXuanWang\MonitorMethod\Models\MonitorMethod;
use WoXuanWang\Point\Models\Point;
use WoXuanWang\Device\Models\Device;
use WoXuanWang\Solution\Models\Solution;
use WoXuanWang\Project\Models\Project;
use WoXuanWang\Organization\Models\Organization;
use WoXuanWang\Supervisor\Models\Supervisor;
use WoXuanWang\DataType\Models\DataType;

class ModelTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user = factory(User::class)->create();
        $company = factory(Company::class)->create([
            'name' => 'XX建设单位',
        ]);
        $customer = factory(Customer::class)->create([
            'name' => $user->name,
            'company_id' => $company->id,
            'user_id' => $user->id
        ]);
        $monitor_method = factory(MonitorMethod::class)->create([
            'name' => '自动'
        ]);
        $device_type = factory(DeviceType::class)->create([
            'name' => '倾斜仪',
            'model' => 'YL-IMG(S)单轴倾斜仪',
            'monitor_method_id' => $monitor_method->id,
        ]);
        $device = factory(Device::class)->create([
            'name' => '倾角计',
        ]);
        $organization = factory(Organization::class)->create([
            'name' => '贵州建筑科学研究检测中心',
            'area_id' => 520000,
            'built_at' => strtotime('December 30 2008')
        ]);
        $user_supervisor = factory(User::class)->create();
        $supervisor = factory(Supervisor::class)->create([
            'name' => $user_supervisor->name,
            'user_id' => $user_supervisor->id,
            'organization_id' => $organization->id,
            'professional_title' => '检测工程师',
            'job_title' => '工程师',
            'education' => '本科',
        ]);
        $project = factory(Project::class)->create([
            'name' => '中天火灾加固高层',
            'company_id' => $company->id,
            'organization_id' => $organization->id,
            'supervisor_id' => $supervisor->id,
            'longitude' => 106.65,
            'latitude' => 26.68,
            'type' => '施工单位'
        ]);
        $solution = factory(Solution::class)->create([
            'name' => '中天火灾加固高层倾斜监测',
            'type' => '倾斜',
            'monitor_method_id' => $monitor_method->id,
            'project_id' => $project->id
        ]);
        $point = factory(Point::class)->create([
            'solution_id' => $solution->id,
            'device_id' => $device->id,
        ]);
        $data_history = factory(DataHistory::class)->create([
            'point_id' => $point->id,
            'device_type_id' => $device_type->id,
        ]);
        $data_type = factory(DataType::class)->create([
            'name' => '立柱竖向位移'
        ]);

        $user1 = factory(User::class)->create();
        $company1 = factory(Company::class)->create([
            'name' => 'XX施工单位',
        ]);
        $customer1 = factory(Customer::class)->create([
            'name' => $user1->name,
            'company_id' => $company1->id,
            'user_id' => $user1->id
        ]);
        $monitor_method1 = factory(MonitorMethod::class)->create([
            'name' => '手动'
        ]);
        $device_type1 = factory(DeviceType::class)->create([
            'name' => '测缝计',
            'monitor_method_id' => '1',
            'model' => 'YL-CDD-A振弦式位移计',
            'monitor_method_id' => $monitor_method->id,
        ]);
        $device1 = factory(Device::class)->create([
            'name' => '测缝计TEST',
        ]);
        $user_supervisor1 = factory(User::class)->create();
        $supervisor1 = factory(Supervisor::class)->create([
            'name' => $user_supervisor1->name,
            'user_id' => $user_supervisor1->id,
            'organization_id' => $organization->id,
            'professional_title' => '检测工程师',
            'job_title' => '工程师',
            'education' => '本科',
        ]);
        $project1 = factory(Project::class)->create([
            'name' => '甘平新村九栋宅监测',
            'company_id' => $company1->id,
            'organization_id' => $organization->id,
            'supervisor_id' => $supervisor1->id,
            'longitude' => 105.62,
            'latitude' => 25.95,
            'type' => '勘察单位',
        ]);
        $solution1 = factory(Solution::class)->create([
            'name' => '甘平新村九栋住宅沉降监测',
            'type' => '建(构)筑物竖向位移',
            'monitor_method_id' => $monitor_method->id,
            'project_id' => $project1->id,
        ]);
        $point1 = factory(Point::class)->create([
            'solution_id' => $solution1->id,
            'device_id' => $device1->id,
        ]);
        $data_history1 = factory(DataHistory::class)->create([
            'point_id' => $point1->id,
            'device_type_id' => $device_type1->id,
        ]);
        $data_type1 = factory(DataType::class)->create([
            'name' => '裂缝'
        ]);
    }
}
